/**
 * Created by DukeCrushIt on 2015/8/17.
 */
//module game{
    class DateSelectItemRender extends eui.ItemRenderer{
        public static NUM:number = 0;
        public constructor(){
            super();
            this.skinName = "pet.DateSelectItemRenderSkin";
            this.name = "dateselectitemrender"+DateSelectItemRender.NUM;
            DateSelectItemRender.NUM++;
        }

        public dataChanged(){
            super.dataChanged();
            this.img_pet.source = GameConst.Res_Root+"resource/assets/petpreview/"+this.data.petId+".png";
            this.lab_name.text = this.data.name;
            this.img_gender_female.visible = this.data.sex == 1;
            this.img_gender_male.visible = this.data.sex == 0;
            this.group_lv.text = this.data.grade+"";
            var war = Model.GetPerAttrs(this.data.petId);
            var tempAttackAdd = 0;
            var tempDefenseAdd = 0;
            //var logo = GuildMgr.getInstance().guildLogo;
            //if( logo){
            //    tempAttackAdd += logo.attrAttack;
            //    tempDefenseAdd += logo.attrDefense;
            //}
            var moodAdd = this.data.mood/50;
            if( war){
                this.lab_attack.text = "攻击："+(Math.round(war.attack*moodAdd) +tempAttackAdd );
                this.lab_defense.text = "防御："+(Math.round(war.defense*moodAdd)+tempDefenseAdd);
                this.lab_speed.text = "速度："+war.speed;
                this.lab_hardness.text = "难度："+war.difficulty;
            }

            if( this.data.petId == PetMgr.getInstance().curIndatePetId){
                DateSelectPanel.getInstance().updateListSelection(this.itemIndex);
            }
        }

        private img_date_render_bottom_selected:eui.Image;
        private img_cap_mark:eui.Image;
        private img_pet:eui.Image;
        private img_gender_female:eui.Image;
        private img_gender_male:eui.Image;
        private lab_name:eui.Label;
        private lab_attack:eui.Label;
        private lab_defense:eui.Label;
        private lab_speed:eui.Label;
        private lab_hardness:eui.Label;
        private group_lv:eui.BitmapLabel;
        public partAdded(name:string, instance:any){
            super.partAdded(name, instance);
            if( name == "img_date_render_bottom_selected"){
                this.img_date_render_bottom_selected = instance;
            }else  if( name == "img_cap_mark"){
                this.img_cap_mark = instance;
            }else  if( name == "img_pet"){
                this.img_pet = instance;
            }else  if( name == "img_gender_female"){
                this.img_gender_female = instance;
            }else  if( name == "img_gender_male"){
                this.img_gender_male = instance;
            }else  if( name == "lab_attack"){
                this.lab_attack = instance;
            }else  if( name == "group_lv"){
                this.group_lv = instance;
            }else  if( name == "lab_defense"){
                this.lab_defense = instance;
            }else  if( name == "lab_name"){
                this.lab_name = instance;
            }else  if( name == "lab_speed"){
                this.lab_speed = instance;
            }else  if( name == "lab_hardness"){
                this.lab_hardness = instance;
            }
        }
    }
//}